package com.loocup.demo.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author loocup
 * @description
 * @since 2019/1/17
 */
@ControllerAdvice
@ResponseBody
public class MyGlobalControllerExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Object globalHandler(Exception e){
        Map<String, Object> map = new HashMap<>();
        map.put("status", "ERROR");
        map.put("code", 505);
        map.put("message", e.getMessage());
        return map;
    }

}
